<% title_tag t("common.login") %>
<%
auth_session = session[:omniauth] || {}
auth_info = auth_session["info"]
%>
<div class="flex flex-col justify-center gap-4 md:flex-row">
  <div class="w-full md:8/12 lg:w-5/12">
    <div class="card card-l6">
      <div class="card-body">
        <div class="card-title"><%= t("common.login") %> <%= Setting.app_name %></div>
        <% if auth_info.present? %>
          <div class="alert">
            登录 <%= Setting.app_name %> 账号，以绑定 <strong><%= Homeland::Utils.omniauth_name(auth_session["provider"]) %></strong> 三方登录。
          </div>
        <% end %>
        <%= form_for resource, as: resource_name, url: session_path(resource_name) do |f| %>
          <%= render "/shared/error_messages", target: resource %>
          <div class="form-group">
            <%= f.text_field :login, class: "form-control form-control-lg", 
              placeholder: t("activerecord.attributes.user.login") + " / " + t("activerecord.attributes.user.email") %>
          </div>
          <div class="form-group">
            <%= f.text_field :password, type: :password, class: "form-control form-control-lg", 
              placeholder: t("activerecord.attributes.user.password") %>
          </div>
          <% if devise_mapping.rememberable? -%>
            <div class="form-group">
              <div class="custom-control custom-checkbox">
                <%= f.check_box :remember_me, class: "custom-control-input" %>
                <label class="custom-form-label" for="user_remember_me"><%= t("common.remember_me") %></label>
              </div>
            </div>
          <% end -%>
          <div class="form-actions">
            <%= f.submit t("common.login"), class: "btn btn-primary btn-lg btn-block", 'data-disable-with' => t("common.logining") %>
          </div>
        <% end %>
      </div>
    </div>
    <% if Setting.omniauth_providers.any? %>
      <div class="mt-6 card omniauth-buttons">
        <div class="card-header"><%= t("common.auth_with_other_services") %></div>
        <div class="flex items-center card-body md:justify-center">
          <% Setting.omniauth_providers.each do |provider| %>
            <%= link_to raw("<i class='fab fa-#{provider}'></i> #{Homeland::Utils.omniauth_name(provider)}"), omniauth_authorize_path(:user, provider), method: :post, class: "btn btn-secondary omniauth-#{provider}" %>
          <% end %>
        </div>
      </div>
    <% end %>
  </div>
  <div class="w-full md:w-4/12 lg:w-3/12">
    <div class="card">
      <%= render partial: "devise/shared/links" %>
    </div>
  </div>
</div>
